package com.groot.medical.service;

import com.groot.medical.dao.ChronicPolicyDAO;
import com.groot.medical.dao.ChronicPolicyDAOImpl;
import com.groot.medical.entity.ChronicPolicy;
import com.groot.medical.entity.PageBean;

public class ChronicPolicyServiceImpl implements ChronicPolicyService {
	private ChronicPolicyDAO chronicPolicyDAO = new ChronicPolicyDAOImpl();

	@Override
	public PageBean findChronicPolicyInfoByPage(int pageNum, int pageSize) {
		int totalRecord = chronicPolicyDAO.getAllChronicPolicyInfoCounts();
		PageBean pageBean = new PageBean<>(pageNum, pageSize, totalRecord);
		int startIndex = pageBean.getStartIndex();
		pageBean.setList(chronicPolicyDAO.findChronicPolicyInfoByPage(startIndex,pageSize));
		return pageBean;
	}

	@Override
	public void addChronicPolicyInfo(ChronicPolicy policy) {
		chronicPolicyDAO.addChronicPolicyInfo(policy);
		
	}
	
	@Override
	public ChronicPolicy findChronicPolicyInfoById(String id) {
		ChronicPolicy policy=chronicPolicyDAO.findChronicPolicyInfoById(id);
		return policy;
	}

	@Override
	public void editChronicPolicyInfo(ChronicPolicy policy) {
		chronicPolicyDAO.editChronicPolicyInfo(policy);
		
	}
	
	@Override
	public ChronicPolicy findChronicPolicyInfoByYear(String nowTime) {
		ChronicPolicy policy=chronicPolicyDAO.findChronicPolicyInfoByYear(nowTime);
		return policy;
	}

}
